local sk__tianyou = fk.CreateSkill {

  name = "sk__tianyou",

  tags = { Skill.Compulsory, },

}



sk__tianyou:addEffect(fk.EventPhaseStart, {
  name = "sk__tianyou",
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__tianyou.name) and player.phase == Player.Finish then
      local events = player.room.logic:getActualDamageEvents(999, function (e)
        local damage = e.data
        if damage.skillName == "lightning_skill" then
          return true
        end
      end, Player.HistoryGame)
      if #events == 0 then
        event:setCostData(self, 0)
        return player:isWounded()
      else
        event:setCostData(self, #events)
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event:getCostData(self) == 0 then
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = sk__tianyou.name,
      })
    else
      player:drawCards(event:getCostData(self), sk__tianyou.name)
    end
  end,
})

return sk__tianyou